const express = require('express');
const app =express()
const path = require('path')
const bodyParse = require('body-parser')
app.get('/',(req,res)=>{
    res.sendFile(path.resolve(__dirname,'./public/add.html'))
})

app.get('/list',(req,res)=>{
    res.render('list',{datas})
})

let datas = []

app.use(express.json())
app.use(express.urlencoded())

app.set('view engine','ejs')
app.set('views',path.resolve(__dirname,'./public'))

let router = express.Router()
router.post('/add',(req,res)=>{
    datas.push(req.body)
    console.log(datas,'===datas')
    res.send('提交成功')
})

app.use('/user',router)
app.listen('3000')